﻿using System;
using System.Collections.Generic;
using System.Reflection;

namespace Eb
{
    // 验证后调用的反馈函数.
    public delegate void OnUCenterVerifyResponse(string token, ulong acc_id,
        string acc, eLoginResult result, Dictionary<string, string> map_param);

    // 验证接口.
    public interface UCenterVerify
    {
        void start(string config_str);

        void stop();

        void update(float elapsed_tm);

        void verify(string token, string account_name, string password, Dictionary<string, string> map_param);

        void logout(string account_name);

        void setResponse(OnUCenterVerifyResponse cb);
    }

    public static class UCenterVerifyHelper
    {
        //---------------------------------------------------------------------
        public static UCenterVerify setupUCenterVerify(string dll_file, string class_name, string config_str)
        {
            Assembly ass = Assembly.LoadFrom(dll_file);// 加载dll文件
            Type tp = ass.GetType(class_name);// 获取类名，命名空间+类名
            UCenterVerify verify = (UCenterVerify)ass.CreateInstance(tp.Name);
            verify.start(config_str);
            return verify;
        }
    }
}
